﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;

public class StartThePuzzle : MonoBehaviour
{
    public TMP_InputField startInputText;
    public GameObject scriptObject;
    string puzzleCodeString;
    int puzzleCode;
    public string theRealPuzzle;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void startTheGame()
    {
        puzzleCodeString = startInputText.text;
        puzzleCode = System.Int32.Parse(puzzleCodeString)/2;
        if(puzzleCode>0&&puzzleCode<= scriptObject.GetComponent<GameManager>().dictionaryA.Length)
        {
            theRealPuzzle = scriptObject.GetComponent<GameManager>().dictionaryA[puzzleCode - 1];
            GlobalObjectScript.Instance.thePuzzle = theRealPuzzle;
            SceneManager.LoadScene(1);
        }
        else if(puzzleCode> scriptObject.GetComponent<GameManager>().dictionaryA.Length)
        {
            theRealPuzzle = scriptObject.GetComponent<GameManager>().dictionaryB[puzzleCode - scriptObject.GetComponent<GameManager>().dictionaryA.Length - 1];
            GlobalObjectScript.Instance.thePuzzle = theRealPuzzle;
            SceneManager.LoadScene(1);
        }
        //theRealPuzzle = System.Int32.Parse(puzzleCode)/2-scriptObject.GetComponent<GameManager>().dictionaryA
    }
}
